package com.tupu.entity.dispatch;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * @TableName tb_standardization_point
 */
@TableName(value = "tb_standardization_point")
@Data
public class StandardizationPoint implements Serializable {
    /**
     *
     */
    //@TableId(type = IdType.INPUT)
    @TableId(type = IdType.AUTO)
    private Integer problemId;

    /**
     * 厂站
     */
    private String station;

    /**
     *
     */
    private Integer stationNo;

    private String deviceName;

    private Integer deviceId;
    /**
     * 设备类型
     */
    private String deviceType;
    private String messageType;

    /**
     * 设备类型编码
     */
    private String deviceTypeCode;

    /**
     * 点名
     */
    private String pointName;

    private String actionName;

    /**
     * 校验规则
     */
    private String checkRules;

    private Double similarity;

    /**
     * 校验结果(1合格、0不合格)
     */
    private Integer validResult;

    public String getCheckResult() {
        return Optional.ofNullable(this.validResult).map(i -> i == 1 ? "合格" : "不合格")
                .orElse(null);
    }

    @TableField(exist = false)
    private String validResultStr;

    /**
     * 主站合并(1是、0否)
     */
    private Integer mainMerge;

    public String getMerge() {
        return Optional.ofNullable(this.mainMerge).map(i -> i == 1 ? "是" : "否")
                .orElse(null);
    }

    @TableField(exist = false)
    private String mainMergeStr;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime recordTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * 设备名称规范表主键id
     */
    private Integer standardId;

    /**
     * 是否训练（0代表取消训练，1代表训练）
     */
    private Integer isTrain;

    /**
     * 是否训练操作
     */
    @TableField(exist = false)
    private String trainOperate;

    /**
     * 训练时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime trainTime;

    @TableField(exist = false)
    private String standardName;

    @TableField(exist = false)
    private String standardDesc;

    /**
     * 信号名称
     */
    @TableField(exist = false)
    private String signalName;

    /**
     * 信号类型
     */
    private String informationType;
}